//
//  ViewController.swift
//  Underlying-StructAndClass
//
//  Created by jianbo.pei on 2023/11/23.
//

import UIKit

//struct Point {
//    var x: Int = 10
//    var y: Int = 20
//}

struct Point {
    var x: Int
    var y: Int
    init() {
        x = 10
        y = 20
    }
}


/// 测试 Swift KVC
///  - class类型且继承NSObject
///  - 属性前用 @objc
class Point1: NSObject {
    @objc var x: Int
    var y: Int
    override init() {
        x = 10
        y = 20
    }
}

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        view.backgroundColor = .red
        
        test()
        test1()
    }

    func test() {
        var p = Point()
        print("p is \(p)")
    }

    func test1() {
        var p = Point1()
        p.setValue(30, forKey: "x")
        print(" setValue x is \(p.x)")
    }
}

